import cv2
img=cv2.imread('yuan.jpg',1)

if img is not None and len(img.shape)==3:
    print('img.shape:',img.shape)
    def show_img(title,img,delay=-1):
        cv2.imshow(title, img)
        if delay == -1:
            cv2.waitKey(0)
        else:
            cv2.waitKey(delay)
    show_img('img',img,-1)
    if img.shape[2]==3:
        b,g,r=cv2.split(img)
        show_img('b',b,-1)
        show_img('g', g,-1)
        show_img('r', r, -1)
    elif img.shape[2]==4:
        b, g, r ,a= cv2.split(img)
        show_img('b', b, -1)
        show_img('g', g, -1)
        show_img('r',r, -1)
        show_img('a', a, -1)
img=cv2.imread('c:/yuan.jpg')
b=img[:,:,0]
g=img[:,:1]
r=img[:,:,2]
m1=cv2.merge((b,g,r))
m2=cv2.merge((r,g,b))